package com.xyzwps.lib.ap;

import javax.lang.model.element.Modifier;
import java.util.Set;

public record Modifiers(AccessLevel accessLevel, boolean isStatic, boolean isFinal, boolean isAbstract,
                        boolean isSealed) {

    public enum AccessLevel {
        PUBLIC,
        PRIVATE,
        PROTECTED,
        DEFAULT;
    }

    public static Modifiers of(Set<Modifier> it) {
        return new Modifiers(
                it.contains(Modifier.PUBLIC) ? AccessLevel.PUBLIC
                        : it.contains(Modifier.PROTECTED) ? AccessLevel.PROTECTED
                        : it.contains(Modifier.PRIVATE) ? AccessLevel.PRIVATE
                        : AccessLevel.DEFAULT,
                it.contains(Modifier.STATIC),
                it.contains(Modifier.FINAL),
                it.contains(Modifier.ABSTRACT),
                it.contains(Modifier.SEALED)
        );
    }


}
